' Counting Loop ' LET START = 7 LET FINISH = 5 FOR I = START TO FINISH PRINT I; NEXT I END
The program is correct in syntax.
The startingValue in the FOR
statement is
7.
This is OK so far as syntax goes.
The program asks to start I
out at 7 and count up to 5.
Since I
is already larger than 5, the loop is just skipped.
Here is a program where this behavior makes better sense:
' Counting Loop with user input ' PRINT "What start do you want" INPUT START ' PRINT "What finish do you want" INPUT FINISH ' FOR COUNT = START TO FINISH PRINT COUNT; NEXT COUNT ' END
Sometimes the data input from a user means that only part of a program should execute. It is nice that this happens automatically without additional statements.
START
and 14 for FINISH
what will the program print?START
and 3 for FINISH
what will the program print?